<!DOCTYPE html>
<html>
<head>
	<title>计算器</title>
    <script type="text/javascript">
        function suanfa(fuha) {
            var num1 = document.getElementById("num1").value;
            var num2 = document.getElementById("num2").value;
            if (fuha == "+") {
                var result = parseInt(num1) + parseInt(num2);
            } else if (fuha == "-") {
                var result = parseInt(num1) - parseInt(num2);
            } else if (fuha == "*") {
                var result = parseInt(num1) * parseInt(num2);
            } else if (fuha == "/") {
                var result = parseInt(num1) / parseInt(num2);
            }
            document.getElementById("result").innerHTML = "结果："+ result;
            
        }
        function add() {
            suanfa("+");
        }
        function sub() {
            suanfa("-");
        }
        function mul() {
            suanfa("*");
        }
        function div() {
            suanfa("/");
        }
        
    </script>
</head>
<body>
	<label for="num1">请输入第一个数字:</label>
	<input type="text" id="num1"><br><br>
	<label for="num2">请输入第二个数字:</label>
    <input type="text" id="num2"><br><br>
    <p id="result">结果</p>
    <input type="text" id="result">122<br><br>
	<button onclick="window.alert('你好')">加法</button>   
    <button onclick="sub()">减法</button>
	<button onclick="mul()">乘法</button>
	<button onclick="div()">除法</button>
	<br><br>
</body>
</html>